// ast
// //////////////////////////////////////////////////////////
var categoryCtx = new ModuleContext('Category','目录');

var categoryUI = new ModuleUI(categoryCtx);

categoryUI.checkEditForm = function(){
	var vConf = {};
	//
 	vConf = [
	{"name":"id","format":"Integer","tip":" 格式错误!"}
	, {"name":"sortNo","format":"Integer","tip":"顺序 格式错误!"}
	];
	var v = new Validator(categoryCtx.EDIT_FORM_ID, vConf, true);
	var ok = v.validate();
	if(!ok){
		return false;
	}
	return true;
}

categoryUI.setViewItem = function(dataObj, viewObj){
	viewObj.setAttribute('class','row');
	viewObj.setAttribute('id', 'XXXListItem_' + dataObj.id);
	var children = DomUtil.getChildren(viewObj);
	children[0].firstChild.value = dataObj['id'];
	children[1].innerHTML = Widget.getView(dataObj['id'], 'hidden');
	children[2].innerHTML = Widget.getView(dataObj['name'], 'text');
	children[3].innerHTML = Widget.getView(dataObj['photo'], 'text');
	//UploadFileUtil.viewMedia(children[3], dataObj['photo'], 'img');
	children[4].innerHTML = Widget.getView(dataObj['sortNo'], 'text');
	//children[5].innerHTML = Widget.getView(dataObj['enabled'], 'switch');
	
	children[5].innerHTML = '';
	var input = Widget.getInput2('enabled', 'switch', dataObj['enabled'], children[5]);
	input.onchange = function(){categoryUI.enableXXX(dataObj['id'], input);};
	
	children[6].innerHTML = Widget.getView(dataObj['created'], 'date');
	children[7].innerHTML = Widget.getView(dataObj['modified'], 'date');
	children[8].firstChild.onclick = function(){categoryUI.editXXX(dataObj.id);};
	children[9].firstChild.onclick = function(){categoryUI.deleteXXX(dataObj.id);};
}

categoryUI.setEditFiles = function(dataObj){
	dataObj = dataObj||{}; //添加
	UploadFileUtil.editFile2('photo', $E('photo_td'), dataObj['photo']);
}

EventUtil.addEvent(window, 'load', function(){

		
});

//////////////////////////////////////////////////////////